package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appmarket.framework.widget.ArrowImageView;
import com.huawei.appmarket.framework.widget.FoldingTextView;
import com.huawei.appmarket.framework.widget.FoldingTextView.c;
import com.huawei.appmarket.service.store.awk.bean.DetailNoticeCardBean;
import com.huawei.appmarket.service.store.awk.bean.DetailNoticeCardBean.NoticeItemBean;
import java.util.List;
import o.azb;
import o.cgz;
import o.cii;
import o.ckt;
import o.dgh;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;

public class DetailNoticeGeneralCard extends BaseDistCard implements OnClickListener, c {
    private LayoutInflater ʻ;
    protected FoldingTextView ʼ;
    protected ViewGroup ʽ;
    protected TextView ˋ;
    protected ArrowImageView ॱॱ;
    protected DetailNoticeCardBean ᐝ;

    static class b {
        TextView ˊ;
        TextView ˏ;
        RelativeLayout ॱ;

        private b() {
        }
    }

    public /* synthetic */ cgz ˏ(View view) {
        return ˎ(view);
    }

    public DetailNoticeGeneralCard(Context context) {
        super(context);
    }

    public DetailNoticeGeneralCard ˎ(View view) {
        azb.ˏ(view, j.ˎꓸ);
        azb.ॱ(view, j.ˌˏ);
        this.ˋ = (TextView) view.findViewById(j.ʼﾞ);
        this.ॱॱ = (ArrowImageView) view.findViewById(j.ˎꜟ);
        this.ʼ = (FoldingTextView) view.findViewById(j.ˌᐝ);
        this.ʼ.setOnContentChangedListener(this);
        this.ʼ.setMaxLine(3);
        this.ʼ.setResize(true);
        this.ʽ = (ViewGroup) view.findViewById(j.ˍˎ);
        ʽ(view);
        this.ʻ = LayoutInflater.from(this.ʼॱ);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        this.ᐝ = (DetailNoticeCardBean) cardBean;
        ˊ();
        ˋ();
    }

    protected void ˊ() {
        if (this.ˋ != null && !TextUtils.isEmpty(this.ᐝ.v_())) {
            this.ˋ.setText(this.ᐝ.v_());
        }
    }

    protected void ˋ() {
        int i = 2;
        if (this.ᐝ != null && this.ʻ != null) {
            List ॱ = this.ᐝ.ॱ();
            if (ॱ != null && ॱ.size() > 0) {
                Object ˋ = ((NoticeItemBean) ॱ.get(0)).ˋ();
                if (TextUtils.isEmpty(ˋ)) {
                    this.ʼ.setVisibility(8);
                    if (ॱ.size() <= 2) {
                        i = ॱ.size();
                    }
                    this.ʽ.setVisibility(0);
                    for (int i2 = 0; i2 < i; i2++) {
                        View view;
                        b bVar;
                        View inflate;
                        if (i2 > this.ʽ.getChildCount() - 1) {
                            inflate = this.ʻ.inflate(h.ˎˏ, null);
                            b ˊ = ˊ(inflate);
                            inflate.setTag(ˊ);
                            this.ʽ.addView(inflate);
                            view = inflate;
                            bVar = ˊ;
                        } else {
                            inflate = this.ʽ.getChildAt(i2);
                            view = inflate;
                            bVar = (b) inflate.getTag();
                        }
                        ˏ(view, bVar, (NoticeItemBean) ॱ.get(i2));
                    }
                    return;
                }
                this.ʼ.setVisibility(0);
                this.ʼ.setContent(ˋ);
                ˎ();
            }
        }
    }

    private void ˎ() {
        this.ʼ.setOnClickListener(this);
        this.ॱॱ.setOnClickListener(this);
    }

    private b ˊ(View view) {
        b bVar = new b();
        bVar.ॱ = (RelativeLayout) view.findViewById(j.ٴˋ);
        bVar.ˏ = (TextView) view.findViewById(j.ՙᐝ);
        bVar.ˊ = (TextView) view.findViewById(j.ՙˊ);
        return bVar;
    }

    private void ˏ(View view, b bVar, final NoticeItemBean noticeItemBean) {
        if (view != null && bVar != null && noticeItemBean != null) {
            azb.ˏ(view);
            CharSequence ॱ = noticeItemBean.ॱ();
            CharSequence ˏ = noticeItemBean.ˏ();
            if (TextUtils.isEmpty(ॱ)) {
                bVar.ˏ.setVisibility(8);
                bVar.ˊ.setMaxLines(2);
                bVar.ॱ.setMinimumHeight(0);
                int dimensionPixelSize = this.ʼॱ.getResources().getDimensionPixelSize(d.ᐨ);
                bVar.ॱ.setPadding(0, dimensionPixelSize, 0, dimensionPixelSize);
            }
            bVar.ˏ.setText(ॱ);
            bVar.ˊ.setText(ˏ);
            view.setOnClickListener(new ckt(new OnClickListener(this) {
                final /* synthetic */ DetailNoticeGeneralCard ˎ;

                public void onClick(View view) {
                    BaseCardBean baseCardBean = new BaseCardBean();
                    baseCardBean.ˊˋ(this.ˎ.ᐝ.u_());
                    baseCardBean.ॱ(noticeItemBean.ˊ());
                    cii.ˊ().ˊ(this.ˎ.ʼॱ, baseCardBean);
                    this.ˎ.ˏ(noticeItemBean.ˊ());
                }
            }));
        }
    }

    private void ˏ(String str) {
        dgh.ॱ("091202", "url", str);
    }

    public void onClick(View view) {
        ॱॱ();
        this.ʼ.ˎ();
    }

    private void ॱॱ() {
        dgh.ॱ("091201", "action", "click");
    }

    public void ˎ(boolean z, com.huawei.appmarket.framework.widget.FoldingTextView.b bVar, String str, String str2) {
        if (z && this.ॱॱ != null) {
            if (this.ॱॱ.getVisibility() == 8) {
                this.ॱॱ.setVisibility(0);
            }
            if (bVar == com.huawei.appmarket.framework.widget.FoldingTextView.b.All) {
                this.ॱॱ.setArrowUp(true);
            } else {
                this.ॱॱ.setArrowUp(false);
            }
        }
    }
}
